/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.lucava.boatskeeper.server.service;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import java.util.List;
import org.lucava.boatskeeper.client.service.BoatService;
import org.lucava.lib.shared.service.RemoteParameter;
import org.lucava.lib.shared.service.RemoteResponse;
import org.lucava.boatskeeper.server.dao.MockBoatDao;
import org.lucava.boatskeeper.shared.dto.BoatDto;

/**
 *
 * @author glenn
 */
public class BoatServiceImpl extends RemoteServiceServlet implements BoatService {

    @Override
    public List<BoatDto> getBoats() {
        return MockBoatDao.getAll();
    }

    @Override
    public BoatDto getBoat(Integer param) {
        return MockBoatDao.get(param);
    }

    @Override
    public Boolean saveBoat(BoatDto param) {
        if (param.getId() == null) {
            MockBoatDao.add(param);
        } else {
            MockBoatDao.save(param);
        }

        return true;
    }

    @Override
    public Boolean removeBoat(BoatDto param) {
        MockBoatDao.delete(param);
        return true;
    }

    @Override
    public Boolean removeBoats(List<Integer> param) {

        for (Integer id : param) {
            MockBoatDao.delete(MockBoatDao.get(id));
        }
        return true;
    }
}
